package com.ruoyi.process.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.process.domain.ArgoRemind;
import com.ruoyi.process.service.IArgoRemindService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 农事提醒Controller
 * 
 * @author qhr
 * @date 2024-02-27
 */
@RestController
@RequestMapping("/process/remind")
public class ArgoRemindController extends BaseController
{
    @Autowired
    private IArgoRemindService argoRemindService;

    /**
     * 查询农事提醒列表
     */
    @PreAuthorize("@ss.hasPermi('process:remind:list')")
    @GetMapping("/list")
    public TableDataInfo list(ArgoRemind argoRemind)
    {
        startPage();
        List<ArgoRemind> list = argoRemindService.selectArgoRemindList(argoRemind);
        return getDataTable(list);
    }

    /**
     * 导出农事提醒列表
     */
    @PreAuthorize("@ss.hasPermi('process:remind:export')")
    @Log(title = "农事提醒", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, ArgoRemind argoRemind)
    {
        List<ArgoRemind> list = argoRemindService.selectArgoRemindList(argoRemind);
        ExcelUtil<ArgoRemind> util = new ExcelUtil<ArgoRemind>(ArgoRemind.class);
        util.exportExcel(response, list, "农事提醒数据");
    }

    /**
     * 获取农事提醒详细信息
     */
    @PreAuthorize("@ss.hasPermi('process:remind:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(argoRemindService.selectArgoRemindById(id));
    }

    /**
     * 新增农事提醒
     */
    @PreAuthorize("@ss.hasPermi('process:remind:add')")
    @Log(title = "农事提醒", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody ArgoRemind argoRemind)
    {
        System.out.println("controller.argoRemind -> "+argoRemind);
        return toAjax(argoRemindService.insertArgoRemind(argoRemind));
    }

    /**
     * 修改农事提醒
     */
    @PreAuthorize("@ss.hasPermi('process:remind:edit')")
    @Log(title = "农事提醒", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody ArgoRemind argoRemind)
    {
        System.out.println("controller.argoRemind -> "+argoRemind);
        return toAjax(argoRemindService.updateArgoRemind(argoRemind));
    }

    /**
     * 删除农事提醒
     */
    @PreAuthorize("@ss.hasPermi('process:remind:remove')")
    @Log(title = "农事提醒", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(argoRemindService.deleteArgoRemindByIds(ids));
    }
}
